<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\facade\Request;

class School extends Controller
{
    //加入中间，做权限
    protected $middleware = [
        'app\http\middleware\checkAdminToken::class' 	=> ['except' 	=> ['index'] ]
    ];


    public function index()
    {
        $list= \app\common\model\School::all();
        return toResful(200,$list,'');
    }

    //添加学校
    public function create()
    {
        $role=Request::param('role');

         $user=Request::param('user');
        $data=Request::only(['school_name','longitude','latitude','send_cost','send_cost2','commission_rate']);

        $res= Db::table('school')->insert($data);

        //判断返回值
        if($res){
            return toResful(200,$user,'添加学校成功');
        }else{
            return toResful(400,$user,'添加学校失败');
        }

    }



}
